package gray.android.field;

import gray.Field;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

public class BigTextField extends LinearLayout implements Field<String,View>, TextWatcher{
	private final EditText _field;
	
	private BigTextField(Context context, final String name) {
		super(context);
    
		TextView txt = new TextView(context);
		txt.setText(name);
    txt.setTextColor(0xFF000000);
		_field = new EditText(context);
		_field.addTextChangedListener(this);
		_field.setLines(8);
		//requestFocus();
    _field.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                                            LayoutParams.WRAP_CONTENT));
    addView(txt);
		addView(_field);
	}

	public static Field<String, View> factory(Context context, final String name, final Character key){
		return new BigTextField(context,name);
	}
	
	@Override
	public View container() {
		// TODO Auto-generated method stub
		return this;
	}

	@Override
	public Boolean ready() {
		return true;
	}

	@Override
	public String input() {
		return _field.getText().toString();
	}
	
	@Override
	public void afterTextChanged(Editable arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
			int arg3) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onTextChanged(CharSequence s, int start, int before, int count) {
		// TODO Auto-generated method stub
		
	}
}
